<?php
namespace app\models;

use Yii;
use app\librarys\DbCacheUtility;

/**
 * 三级区域体系
 * Class Area
 * @package app\models
 */
class Area
{
    /**
     * 获取物流三级体系数据
     * @param string|null $parentId 如果为null,则获取"省"级数据
     * @return mixed
     */
    public static function getAreaList($parentId)
    {
        $parentId = $parentId == null ? '' : $parentId;
        $sql = "SELECT code,name,id FROM t_area WHERE parent_id = :parent_id ORDER BY code asc";
        $cmd = \Yii::$app->db->createCommand($sql);
        $cmd->bindValue(':parent_id', $parentId);
        $result = DbCacheUtility::queryAll($cmd, 60 * 60);
        return $result;
    }
}